#pragma once

#include <pthread.h>

class Mutex
{
public:
    Mutex()
    {}

    void Lock()
    {
        pthread_mutex_lock(&mutex);
    }

    void UnLock()
    {
        pthread_mutex_unlock(&mutex);
    }

    ~Mutex()
    {
        pthread_mutex_destroy(&mutex);
    }
private:
    pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
};

class LockGuard
{
public:
    LockGuard()
    {
        mutex.Lock();
    }

    ~LockGuard()
    {
        mutex.UnLock();
    }
private:
    Mutex mutex;
};